package com.itheima.web;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.domain.company.Company;
import com.itheima.service.company.CompanyService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.UUID;

@Controller
public class ApplyController {

    @Reference
    private CompanyService companyService;

    @RequestMapping(value = "/apply")
    public @ResponseBody String apply(Company company){
        //System.out.println(company.toString());
        /**
         * Company{id='null', name='晓东洗脚城', expirationDate=null, address='北京',
         * licenseId='null', representative='晓东', phone='123', companySize='100000',
         * industry='服务行业', remarks='null', state=null, balance=null, city='null'}
         */
        try {
            company.setId(UUID.randomUUID().toString());
            company.setState(0);
            companyService.save(company);
            return "1";
        }catch (Exception e){
            e.printStackTrace();
            return "2";
        }
    }
}
